package com.zggk.lzz.sjxq;

import android.app.Activity;

import com.alibaba.fastjson.JSON;
import com.zggk.lzz.api.MyApplication;
import com.zggk.lzz.api.Urls;
import com.zggk.lzz.callback.StringDialogCallback;
import com.zggk.lzz.mvp.BasePresenterImpl;
import com.lzy.okgo.OkGo;
import com.lzy.okgo.model.Response;

/**
 * MVPPlugin
 *  邮箱 784787081@qq.com
 */

public class SjxqPresenter extends BasePresenterImpl<SjxqContract.View> implements SjxqContract.Presenter{
    @Override
    public void getData(String id, Activity activity) {
        OkGo.<String>post(Urls.JAVASERVER+"pms/rhms/lzzapp/getEnentInfoById")
                .params("token", "Bearer$" + MyApplication.spUtils.getString("Token",""))
                .params("id", id)
                .execute(new StringDialogCallback(activity) {
                    @Override
                    public void onSuccess(Response<String> response) {
                        SjxqBean sjxqBean = JSON.parseObject(response.body(),SjxqBean.class);
                        if (mView == null)
                            return;
                        if (sjxqBean.getCode().equals("200")){
                            mView.getDatas(sjxqBean.getData());
                        }else {
                            mView.onRequestError(sjxqBean.getMessage());
                        }
                    }
                });
    }
}
